﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Maticsoft.DBUtility;
using System.Data;
using System.Data.SqlClient;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// PaperReadAuth数据类
    /// </summary>
    public class PaperReadAuth
    {

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-25</date>
        /// <param name="strWhere">查询条件</param>
        /// <returns>数据列表</returns>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select FPaperId,FSourceNo,FProp,FPronoun,FEntityNo ");
            strSql.Append(" FROM t_PaperReadAuth ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取权限数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-25</date>
        /// <param name="paperID">题目编号</param>
        /// <returns>数据列表</returns>
        public DataSet GetListAuth(decimal paperID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * FROM v_PaperReadAuth where FPaperId=@FPaperId");

            SqlParameter[] parameters = {
					new SqlParameter("@FPaperId",SqlDbType.Decimal)};
            parameters[0].Value = paperID;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 删除权限数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-25</date>
        /// <param name="fPaperId">编号</param>
        /// <param name="fSourceNo">操作人员</param>
        /// <param name="fPronoun">部门，个人，全部</param>
        /// <param name="fProp">类型</param>
        /// <param name="fEntityNo">公司编号</param>
        public void DeleteDept(decimal fPaperId, string fSourceNo, string fPronoun, string fProp, string fEntityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from t_PaperReadAuth ");
            strSql.Append(" where FPaperId=@FPaperId and FSourceNo=@FSourceNo and FProp=@FProp and FPronoun=@FPronoun and FEntityNo=@FEntityNo");

            SqlParameter[] parameters = {
					new SqlParameter("@FPaperId", SqlDbType.Decimal,9),
					new SqlParameter("@FSourceNo", SqlDbType.NVarChar,25),
					new SqlParameter("@FProp", SqlDbType.Char,1),
					new SqlParameter("@FPronoun", SqlDbType.NVarChar,25),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,15)};
            parameters[0].Value = fPaperId;
            parameters[1].Value = fSourceNo;
            parameters[2].Value = fProp;
            parameters[3].Value = fPronoun;
            parameters[4].Value = fEntityNo;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

        }

    }
}
